import request from "@/utils/request.js";

export function like(articleId) {
    return request({
        url: '/articles/articles/like/' + articleId,
        method: 'put',
    })
}

export function getIndexArticle(){
    return request({
        url: '/articles/articles/getIndexArticle',
        method: 'get',
    })
}

/**
 * 获取文章详情
 * @param articleId
 * @returns {*}
 */
export function loadArticleDetail(articleId) {
    return request({
        url: '/articles/articles/getArticleDetail/' + articleId,
        method: 'get',
    })
}

/**
 * 查询所有已审核的文章
 * @returns {*}
 */
export function getArticleList() {
    return request({
        url: '/articles/articles/getReviewedArticles',
        method: 'get'
    })
}

// 查询文章管理列表
export function listArticles(query) {
    return request({
        url: '/articles/articles/list',
        method: 'get',
        params: query
    })
}

// 查询文章管理详细
export function getArticles(articleId) {
    return request({
        url: '/articles/articles/' + articleId,
        method: 'get'
    })
}

// 新增文章管理
export function addArticles(data) {
    return request({
        url: '/articles/articles',
        method: 'post',
        data: data
    })
}

// 修改文章管理
export function updateArticles(data) {
    return request({
        url: '/articles/articles',
        method: 'put',
        data: data
    })
}

// 删除文章管理
export function delArticles(articleId) {
    return request({
        url: '/articles/articles/' + articleId,
        method: 'delete'
    })
}

/**
 * 修改文章发布状态
 * @param articleId
 * @param isPublish
 * @returns {*}
 */
export function changePublishStatus(articleId, isPublish) {
    return request({
        url: '/articles/articles/changePublishStatus',
        method: 'put',
        data: {
            articleId,
            isPublish,
        }
    })
}
